﻿<%@page contentType ="text/html; charset=UTF-8" %> 
<%@ page import="java.awt.*"%>
<%@ page import="java.awt.image.*"%>
<%@ page import="java.util.*"%>
<%@ page import="javax.imageio.*"%>



<%

     
     out.clear();   
     response.setHeader("Pragma","No-cache");   
     response.setHeader("Cache-Control","no-cache");   
     response.setDateHeader("Expires",   0); 
	 
    

    int iWidth = 70, iHeight = 18;
    BufferedImage image = new BufferedImage(iWidth, iHeight,BufferedImage.TYPE_INT_RGB);
   
    Graphics g = image.getGraphics();
    

    g.setColor(Color.white);
    g.fillRect(0, 0, iWidth, iHeight);
   

    g.setColor(Color.black);
    g.drawRect(0, 0, iWidth - 1, iHeight - 1);
  

    Random random = new Random();
    String rand = String.valueOf(Math.random()*10000);
   // String randChar = "y0p9s1k5vb4NB6KH7GFDA8E";
    String temp="" ;
    
    for(int i=0;i<4;i++)
    {
    //   temp =temp+randChar.charAt(random.nextInt(23));
	   temp = temp + random.nextInt(23);
    }

    if(temp.length()>=4){
	   temp = temp.substring(0,4);
	}else{
	    do{
				temp = temp + "0";

			}while(temp.length()<4);
			
	}
 
    session.setAttribute("TOKEN", temp.toLowerCase());

    g.setColor(Color.black);
    
    g.setFont(new Font("Times New Roman", Font.PLAIN, 20));
    g.drawString(temp, 10, 15);

    
    for (int iIndex = 0; iIndex < 88; iIndex++) {
        int x = random.nextInt(iWidth);
        int y = random.nextInt(iHeight);
        g.drawLine(x, y, x, y);
        
    }
    

    g.dispose();

    
    ImageIO.write(image, "JPEG", response.getOutputStream());
   // out.clear();
    out = pageContext.pushBody();
   // response.getOutputStream().close();
%>
